package com.xmb.wechat.view.wechat.money;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.widget.TextView;

import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.entity.withDrawEntity;
import com.xmb.wechat.util.MoneyFormat;

import butterknife.BindView;

/**
 * @Author lijiangop
 * @CreateTime 2020/4/15 08:47
 */
public class WechatFundWithdrawDetailActivity extends BaseActivity {

    @BindView(R2.id.tv_expected_time)
    TextView mTvExpectedTime;
    @BindView(R2.id.tv_money)
    TextView mTvMoney;
    @BindView(R2.id.tv_bank)
    TextView mTvBank;
    @BindView(R2.id.tv_service_charge)
    TextView mTvServiceCharge;

    public WechatFundWithdrawDetailActivity() {
        super(R.layout.activity_fund_withdraw_detail);
    }

    public static void start(Activity act, withDrawEntity withDrawEntity) {
        Intent it = new Intent(act, WechatFundWithdrawDetailActivity.class);
        it.putExtra("deliver", withDrawEntity);
        act.startActivity(it);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void initView() {
        setStatusBarColor(Color.parseColor("#ffffff"));
        setNavigationColor(Color.parseColor("#f7f7f7"));
        //字体
        AssetManager mgr = getAssets();
        Typeface tf = Typeface.createFromAsset(mgr, "fonts/WeChatLqNumber.ttf");
        mTvBank.setTypeface(tf);
        mTvMoney.setTypeface(tf);
        mTvServiceCharge.setTypeface(tf);

        withDrawEntity withDrawEntity = (withDrawEntity) getIntent().getSerializableExtra("deliver");
        if (withDrawEntity != null) {
            mTvMoney.setText("¥" + MoneyFormat.formatMoney(withDrawEntity.getMoney()));
            mTvBank.setText(withDrawEntity.getBanCard());
            mTvExpectedTime.setText("预计" + withDrawEntity.getDealTime() + "到账");
            if (withDrawEntity.isServiceChargeFree()) {
                mTvServiceCharge.setTextColor(getResources().getColor(R.color.yellow_70));
                mTvServiceCharge.setText("本次提现免费");
            } else {
                double money = withDrawEntity.getMoney();
                double v = money / 1000;
                double max = Math.max(v, 0.01);
                mTvServiceCharge.setText("¥" + MoneyFormat.formatMoney(max));
            }
        }
    }
}
